#include "myplane.h"
#include <shuju.h>

myplane::myplane()
{
    plane.load(":/pic/res/feiji.png");
    //飞机坐标；
    x = (sence_w - plane.width())*0.5;
    y = sence_h- plane.height();
    //飞机碰撞体积；
    Rect.setWidth(plane.width());
    Rect.setHeight(plane.height());
    Rect.moveTo(x , y);
}

void myplane::shoot()
{
    //时间间隔
    recode++;
    if(recode < 60)
    {
        return;
    }
   //可发射时
    recode = 0;
    for(int i = 0; i < 30;i++)
    {
        if(bullets[i].b_free == 1)
        {
            bullets[i].b_free = 0;
            //子弹位置
            bullets[i].b_x = x + Rect.width()*0.5;
            bullets[i].b_y = y ;
            break;
        }
    }
}

void myplane::setposition(int x, int y)
{
    this->x = x;
    this->y = y;
    Rect.moveTo(x , y);
}